<?php
namespace Portal\Controller;

use Common\Controller\HomebaseController;

class SearchController extends HomebaseController {
    
    //搜索结果页面
    public function index() {
		$keyword = I('request.searchword/s','');
		if (empty($keyword)) {
			$this -> error("关键词不能为空！请重新输入！");
		}
		$posts_model = D('Portal/PortalPosts');
	    $where['a.post_title'] = array('like','%'.$keyword.'%');
	    $posts_list = $posts_model
		    ->alias('a')
		    ->join('join __PORTAL_TERM_RELATIONSHIPS__ as b ON a.id = b.object_id')
		    ->where($where)
		    ->select();
	    $this -> assign("posts_list",$posts_list);
		$this -> assign("keyword", $keyword);
		$this -> display(":search");
    }
    
}
